package hotciv.view;

import hotciv.framework.Game;

import java.awt.Point;
import java.awt.event.MouseEvent;

import minidraw.framework.Drawing;
import minidraw.framework.DrawingEditor;
import minidraw.framework.Figure;
import minidraw.standard.ImageFigure;
import minidraw.standard.NullTool;


/** A tool to 'end the turn' of a game. */
public class EndOfTurnTool extends NullTool {
  private Game game;
  private DrawingEditor editor;

  public EndOfTurnTool(DrawingEditor editor, Game game) {
    this.editor = editor;
    this.game = game;
  }
  @Override
public void mouseDown(MouseEvent e, int x, int y) {
    Drawing drawing = editor.drawing();
    Figure f = drawing.findFigure(x,y);
    if ( f != null &&
         f instanceof ImageFigure ) {
      if ( f.displayBox().
           contains( new Point( GfxConstants.TURN_SHIELD_X,
                                GfxConstants.TURN_SHIELD_Y) ) ) {
        // OK, the turn shield has been clicked.
        game.endOfTurn();
        editor.showStatus("Next player: "+game.getPlayerInTurn() );
      }
    }
  }
}
